chore: setup husky and lint-staged pre-commit hook#206
Conversation
|
Warning Review limit reached
More reviews will be available in 3 minutes and 10 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. 📝 WalkthroughWalkthroughAdds Husky and lint-staged, configures a ChangesPre-commit Linting Infrastructure
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Around line 17-21: The lint-staged config in package.json incorrectly matches
monorepo files and ignores staged filenames because it uses "*.{js,jsx}" with
the web-dashboard npm run lint that executes "eslint ."; update lint-staged to
scope patterns to the web-dashboard directory (e.g.,
"apps/web-dashboard/**/*.{js,jsx}") and invoke eslint directly so lint-staged
will pass filenames (replace the current "npm run lint --workspace=web-dashboard
--" entry with a direct "eslint" command), and if other workspaces need linting
add workspace-specific patterns referencing their eslint configs (e.g.,
apps/dashboard-api/**/* .js -> "eslint --config
apps/dashboard-api/eslint.config.js") so each workspace is linted with the
correct config and only staged files are checked.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4107ab00-3b39-4d4f-b2ef-aceb1c4cda9a
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
.husky/pre-commitpackage.json
|
Now mergable? @coderabbitai |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
echo "=== PR Status ==="
gh pr view 206 --repo geturbackend/urBackend --json state,mergeable,mergeStateStatus,reviewDecision,statusCheckRollup
echo ""
echo "=== Open Review Comments ==="
gh pr view 206 --repo geturbackend/urBackend --json reviews,comments
echo ""
echo "=== PR Checks ==="
gh pr checks 206 --repo geturbackend/urBackend
echo ""
echo "=== Review Threads ==="
gh api repos/geturbackend/urBackend/pulls/206/comments --jq '[.[] | {id, body, path, line, user: .user.login, in_reply_to_id}]'Length of output: 24220
✅ Passing
⏳ Still running
The only reason the merge state is marked UNSTABLE is because those two CI checks haven't finished yet. There are no unresolved review comments blocking the merge. Once |
|
all ci done also please give summary of the pr and |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
echo "=== PR Merge State ==="
gh pr view 206 --repo geturbackend/urBackend --json state,mergeable,mergeStateStatus,reviewDecision,statusCheckRollup
echo ""
echo "=== PR Checks ==="
gh pr checks 206 --repo geturbackend/urBackendLength of output: 3452
PR Summary —
|
| File | Change |
|---|---|
package.json (root) |
Added prepare script, lint-staged config, and husky + lint-staged devDependencies |
.husky/pre-commit |
New hook file that runs npx lint-staged on every commit |
How it works — end to end
sequenceDiagram
participant Dev as Developer
participant Git as Git (commit)
participant Husky as Husky (.husky/pre-commit)
participant LS as lint-staged
participant ESLint as ESLint (web-dashboard)
Dev->>Git: git commit -m "..."
Git->>Husky: triggers pre-commit hook
Husky->>LS: npx lint-staged
LS->>LS: filters staged files matching<br/>apps/web-dashboard/**/*.{js,jsx}
LS->>ESLint: runs eslint on those files only
alt ESLint passes
ESLint-->>Dev: ✅ commit succeeds
else ESLint fails
ESLint-->>Dev: ❌ commit blocked — fix lint errors first
end
Step-by-step breakdown
-
huskyis installed as a devDependency and the"prepare": "husky"script ensures the hooks are registered automatically whenever anyone runsnpm install— no manual setup needed for new contributors. -
.husky/pre-commitis a shell script that Git calls before finalising any commit. It simply runsnpx lint-staged. -
lint-stagedis smart — instead of linting the entire codebase (which would be slow), it only lints files that are currently staged (git add-ed). The config in rootpackage.jsontargets:apps/web-dashboard/**/*.{js,jsx}and runs ESLint on those files via the workspace lint command.
-
If ESLint finds errors → commit is blocked until the developer fixes them. If everything is clean → commit goes through normally.
Why this matters
- 🚫 Prevents linting errors from being committed to the repo
- ⚡ Fast — only lints staged files, not the whole codebase
- 🤝 Zero-config for new contributors — hooks install automatically on
npm install
|
got it everything is perfect |
Hey @yash-pouranik, glad I was able to contribute to the project. |
🚀 Pull Request Description
Fixes #202
Set up Husky and lint-staged to run ESLint on staged JavaScript/React files before commits.
Changes Made:
🛠️ Type of Change
🧪 Testing & Validation
Backend Verification:
npm testin thebackend/directory and all tests passed.Frontend Verification:
npm run lintin thefrontend/directory.📸 Screenshots / Recordings (Optional)
✅ Checklist
Built with ❤️ for urBackend.
Summary by CodeRabbit